/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = ora_packet.h                                       */
/*  NOTE      =                                                    */
/*  DATE      = 2014/09/29 by songbb                               */
/*******************************************************************/

#ifndef __ORA_PACKET_H_
#define __ORA_PACKET_H_

/* 默认最大阈值，8i中为4086，9i和10g中为32767，11g中为65535，12c中为2097152，此处使用的是12c的阈值 */
#define APM_ORA_PKT_MAX_LEN 2097152

#define APM_ORA_PACKET_FRAGMENTED 0
#define APM_ORA_PACKET_UNFRAGMENTED 1
#define APM_ORA_PACKET_ERROR 2

#define APM_ORA_CHECK_FRAGMENT_SUCCESS 0
#define APM_ORA_CHECK_FRAGMENT_NEED_NEXT_PACKET 1
#define APM_ORA_CHECK_FRAGMENT_ERROR 2

typedef struct __st_ora_header
{
    unsigned int ui_pkt_len;
    Ora_tns_type tns_type;
    char c_options;
    unsigned short us_dataflag;
} Ora_header;

int ora_header_detect(char *p_payload
                    , unsigned int ui_payload_len
                    , int *p_i_large_sdu_flag);

int ora_header_unpack(L7session_ora *p_st_sess
                    , char *p_payload
                    , unsigned int ui_payload_len
                    , Ora_header *p_st_ora_header);

int ora_init_ora_packet(L7_ora_packet *p_st_ora_packet);

int ora_packet_prepare_data(L7session_ora *p_st_sess
                            , Apm_packet *p_st_packet
                            , L7_ora_packet *p_st_ora_packet);

#endif
